<template>
	<view>
		<view style="margin-top: 20%;">
			<image src="../../static/logo2.png"></image>
		</view>
		<view class="login">
			<view>
				<view class="tu">
					<u--input placeholder="202/302……" prefixIcon="man-add-fill"
						prefixIconStyle="font-size: 20px;color: #909399" type="number" v-model="tel"
						class="ivu-input"></u--input>
				</view>
				<view class="tu" style="margin-top: 20px;">
					<u--input :placeholder="$t('test.psd')" prefixIcon="lock-fill"
						prefixIconStyle="font-size: 20px;color: #909399" type="password" v-model="psd"
						class="ivu-input"></u--input>
				</view>
				<view class="xuanze">
					<label>
						<checkbox :checked="rembertel"  @click="changecheck()"/><text class="zi">{{$t('test.rempsd')}}</text>
					</label>
					<label style="margin-left: 50px;display: flex;" @click="gotofindPwd()">
						<u-icon name="question-circle-fill" color="gray" size="22"></u-icon>
						<text class="zi" style="padding-left: 5px;">{{$t('test.forgetpsd')}}</text>
					</label>
				</view>
			</view>
		</view>
		<view>
			<u-button type="default" shape="circle" class="loginbtn"
				@click="gotologin()">{{$t('test.login')}}</u-button>
			<!-- <button type="default" >访客用户</button> -->
			<u-button type="default" @click="gotofangke()" icon="person-delete-fill" :text="$t('test.login-tourist')"
				id="fangke"></u-button>
		</view>
		<view class="di">

			<view @click="gotoregit()">
				<u-icon name="plus-people-fill" :label="$t('test.regit')" labelPos="bottom" color="gray"
					label-size="14px" size="28" class="tubiao"></u-icon>
			</view>
			<view @click="onlanguagechange()"><u-icon name="setting" :label="$t('test.lang')" label-size="14px"
					labelPos="bottom" color="gray" size="28" class="tubiao"></u-icon>
			</view>
			<view><u-icon name="info-circle" :label="$t('test.us')" labelPos="bottom" @click="gotoabout()"  color="gray" label-size="14px"
					size="28" class="tubiao"></u-icon></view>
		</view>
	</view>
</template>
<script>
	import { getResponseData, showToastTip,getBaseUrl,getWsUrl} from "@/api/req.js";
	
	export default {
		data() {
			return {
				"tel": "",
				"psd": "",
				rembertel:false
			}
		},
		onLoad() {
			var lang = uni.getStorageSync("UNI_LOCALE");
			if(lang==null || lang=="" || lang==undefined){
				uni.setStorageSync("UNI_LOCALE","zh");
			}
			var token = uni.getStorageSync('token');
			if(token!=null && token!="" && token!=undefined){
				uni.switchTab({
					url: "./index"
				})
			}
			this.tel=uni.getStorageSync("etlSim");
			this.rembertel=uni.getStorageSync("rembertel");
		},
		methods: {
			onlanguagechange() {
				uni.navigateTo({
					url: "../api/langchange"
				})
			},
			changecheck(){
				this.rembertel=!this.rembertel;
			},
			gotologin() {
				if(this.tel==""){
					uni.showToast({
						title: this.$t('test.noAccountInput'),
						icon: 'none',
						duration: 2000
					})
					return;
				}
				if(this.psd==""){
					uni.showToast({
						title: this.$t('test.noAccountInput'),
						icon: 'none',
						duration: 2000
					})
					return;
				}
				// uni.showLoading({
				// 	title:this.$t("test.isLoging"),  //"登录中...",
				// 	mask:true
				// })
				
				// if(this.tel!="" && this.psd!=""){
					var that = this;
					var userInfo = {
						etlSim: this.tel,
						password: this.psd
					};
					getResponseData("/userInfo/appLogin",'get',{
						etlSim: this.tel,
						password: this.psd
					},function(res){
						
				
					// uni.request({
					// 	url: 'http://192.168.1.30:8081/userInfo/appLogin',
					// 	data: {
					// 		etlSim: this.tel,
					// 		password: this.psd
					// 	},
					// 	success: (res) => {
						// console.log(res);
							if (res.code == 200) {
								uni.setStorageSync('rembertel', that.rembertel);
								uni.setStorageSync('token', res.data.token);
								// if(that.rembertel){
								  uni.setStorageSync('etlSim', res.data.userInfo.etlSim);
								// }else{
								// 	 uni.setStorageSync('etlSim', "");	
								// }
								uni.switchTab({
									url: "./index"
								})
							}else{
								uni.showToast({
									title: res.msg,
									icon: 'none',
									duration: 2000
								})
							}
						}
						);
					// });
				// }
			},
			gotoregit() {
				uni.navigateTo({
					url: './regit'
				})
			},
			gotoabout() {
				uni.navigateTo({
					url: './about'
				})
			},
			
			gotofangke() {
				uni.navigateTo({
					url: './fangke'
				})
			},
			gotofindPwd() {
				uni.navigateTo({
					url: './findPwd'
				})
			}


		}
	}
</script>

<style>
	page {
		background-color: white;
	}

	image {
		display: block;
		margin: 0 auto;
		width: 200rpx;
		height: 200rpx;
		padding-top: 30px;
	}

	// 设置输入框样式
	.ivu-input {
		border-top: none !important;
		border-left: none !important;
		border-right: none !important;
	}

	.zi {
		font-size: 14px;
		line-height: 25px;
	}

	.tu {
		width: 475rpx;
	}

	.login {
		margin-top: 30px;
		display: flex;
		justify-content: center;
	}

	.xuanze {
		display: flex;
		margin-top: 20px;
	}

	.loginbtn {
		width: 475rpx !important;
		background-color: #014099;
		font-size: 14px;
		height: 40px;
		line-height: 40px;
		margin-top: 10px;
		border-radius: 20px;
		color: white;
		font-weight: bold;

	}

	#fangke {
		width: 475rpx;
		background-color: #014099;
		font-size: 12px;
		height: 40px;
		line-height: 40px;
		margin-top: 10px;
		border-radius: 20px;
		color: white;
	}

	.di {
		position: absolute;
		bottom: 0px;
		display: flex;
		justify-content: space-between;
		width: 100%;
	}

	.di>view {
		width: 430rpx;
		padding-bottom: 10px;
	}
</style>